package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11);unique;comment:手机号"`
	Password string `gorm:"type:char(32);comment:密码"`
}

type RealName struct {
	gorm.Model
	UserId   int64  `gorm:"type:int(11);comment:用户id"`
	RealName string `gorm:"type:char(3);comment:姓名"`
	IdCord   string `gorm:"type:char(18);comment:身份证"`
	Status   int64  `gorm:"type:tinyint(1);default:1;comment:状态:1:待审核,2:审核通过"`
}

func (u *User) Create() error {
	return Db.Create(&u).Error
}
func (u *User) UserGetMobile(mobile string) error {
	return Db.Where("mobile = ?", mobile).Limit(1).Find(&u).Error
}
func (r *RealName) Create() error {
	return Db.Create(&r).Error
}
func (r *RealName) RealNameInfo(userId int64, realName string) error {
	return Db.Where("user_id = ? or real_name = ?", userId, realName).Limit(1).Find(&r).Error
}
func (r *RealName) UpdateExamine(realId, status int64) error {
	return Db.Model(&RealName{}).Where("id = ?", realId).Update("status", status).Limit(1).Find(&r).Error
}
